<?php

//phpinfo();
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

//phpinfo();
$con = pg_connect('host=192.168.43.5 dbname=monografia user=postgres');
$mongo = new Mongo('mongodb://192.168.43.5:27017');
$mono = $mongo->monografia;
$colUrl = $mono->url;
$colUrl->drop();
$colUrl->ensureIndex(array('hash' => 1), array("unique" => true));
$query = pg_query('select * from url');
$i = 0;
while ($res = pg_fetch_assoc($query)) {
    $res['datacriacao'] = new MongoDate(strtotime($res['datacriacao']));
    $colUrl->insert($res);
    $i++;
    echo $i . PHP_EOL;
}
